package com.fr.cell;

import com.fr.base.FRContext;
import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.cell.core.GridUtils;
import com.fr.cell.editor.CellEditor;
import com.fr.cell.editor.FloatEditor;
import com.fr.cell.editor.GeneralCellEditor;
import com.fr.cell.editor.GeneralFloatEditor;
import com.fr.cell.event.CellEditorEvent;
import com.fr.cell.event.CellEditorListener;
import com.fr.cell.event.FloatEditorEvent;
import com.fr.cell.event.FloatEditorListener;
import com.fr.report.CellElement;
import com.fr.report.DefaultCellElement;
import com.fr.report.FloatElement;
import com.fr.report.Report;
import com.fr.report.ReportSettings;
import com.fr.report.TemplateReport;
import com.fr.report.cellElement.CellGUIAttr;
import com.fr.report.cellElement.CellImage;
import com.fr.report.core.DynamicValueList;
import com.fr.report.core.PaintUtils;
import com.fr.report.core.ReportHelper;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

public class Grid extends BaseGridComponent
{
  private boolean showGridLine = true;
  private Color gridLineColor = Color.lightGray;
  private boolean isShowPaginateLine = true;
  private Color paginationLineColor = Color.RED;
  private boolean isShowVerticalFrozenLine = true;
  private Color verticalFrozenLineColor = Color.black;
  private boolean isShowHorizontalFrozenLine = true;
  private Color horizontalFrozenLineColor = Color.black;
  private Color selectedBackground = new Color(150, 150, 255);
  private Color selectedBorderLineColor = Color.black;
  private boolean editable = true;
  private boolean cellSelectable = true;
  private boolean supportCellEditorDef = false;
  private boolean cellDragable = true;
  private boolean isDragPermited = false;
  private boolean isDataChanged = false;
  private FloatElement drawingFloatElement = null;
  private int dragType = GridUtils.DRAG_NONE;
  private Rectangle dragRectangle = null;
  private Point tooltipLocation = new Point();
  private int tabMoveDirection = 0;
  private int enterMoveDirection = 0;
  protected transient Component editorComponent;
  protected transient Point2D editorComponentLoc;
  protected transient CellElement editingCellElement;
  protected transient CellEditor cellEditor;
  protected transient FloatEditor floatEditor;
  protected transient int editingColumn;
  protected transient int editingRow;
  protected transient Hashtable defaultCellEditorsByClass;
  protected transient Hashtable defaultFloatEditorsByClass;
  private int verticalValue = 0;
  private int verticalExtent = 30;
  private int horizontalValue = 0;
  private int horizontalExtent = 20;
  private int verticalBeginValue = 0;
  private int horizontalBeginValue = 0;
  private CellEditorListener innerCellEditorListener = new CellEditorListener(this)
  {
    private final Grid this$0;

    public void editingStopped()
    {
      Grid.access$000(this.this$0, false);
    }

    public void editingCanceled()
    {
      this.this$0.cancelEditing();
    }
  };
  private FloatEditorListener innerFloatEditorListener = new FloatEditorListener(this)
  {
    private final Grid this$0;

    public void editingStopped()
    {
      Grid.access$100(this.this$0, false);
    }

    public void editingCanceled()
    {
      this.this$0.cancelEditing();
    }
  };

  public Grid()
  {
    enableEvents(56L);
    GridKeyAction.initGridInputActionMap(this);
    GridMouseAdapter localGridMouseAdapter = new GridMouseAdapter(this);
    addMouseListener(localGridMouseAdapter);
    addMouseMotionListener(localGridMouseAdapter);
    addMouseWheelListener(localGridMouseAdapter);
    addKeyListener(new GridKeyListener(this));
    setFocusTraversalKeysEnabled(false);
    setOpaque(false);
    setUI(new GridUI());
  }

  public boolean isShowGridLine()
  {
    return this.showGridLine;
  }

  public void setShowGridLine(boolean paramBoolean)
  {
    boolean bool = this.showGridLine;
    this.showGridLine = paramBoolean;
    firePropertyChange("showGridLine", bool, isShowGridLine());
    getReportPane().repaint();
  }

  public Color getGridLineColor()
  {
    return this.gridLineColor;
  }

  public void setGridLineColor(Color paramColor)
  {
    Color localColor = this.gridLineColor;
    this.gridLineColor = paramColor;
    firePropertyChange("girdLineColor", localColor, this.gridLineColor);
    getReportPane().repaint();
  }

  public boolean isShowPaginateLine()
  {
    return this.isShowPaginateLine;
  }

  public void setShowPaginateLine(boolean paramBoolean)
  {
    boolean bool = this.isShowPaginateLine;
    this.isShowPaginateLine = paramBoolean;
    firePropertyChange("isShowPaginateLine", bool, this.isShowPaginateLine);
    getReportPane().repaint();
  }

  public Color getPaginationLineColor()
  {
    return this.paginationLineColor;
  }

  public void setPaginationLineColor(Color paramColor)
  {
    Color localColor = this.paginationLineColor;
    this.paginationLineColor = paramColor;
    firePropertyChange("paginationLineColor", localColor, this.paginationLineColor);
    getReportPane().repaint();
  }

  public boolean isShowVerticalFrozenLine()
  {
    return this.isShowVerticalFrozenLine;
  }

  public void setShowVerticalFrozenLine(boolean paramBoolean)
  {
    boolean bool = this.isShowVerticalFrozenLine;
    this.isShowVerticalFrozenLine = paramBoolean;
    firePropertyChange("isShowVerticalFrozenLine", bool, this.isShowVerticalFrozenLine);
    getReportPane().repaint();
  }

  public Color getVerticalFrozenLineColor()
  {
    return this.verticalFrozenLineColor;
  }

  public void setVerticalFrozenLineColor(Color paramColor)
  {
    Color localColor = this.verticalFrozenLineColor;
    this.verticalFrozenLineColor = paramColor;
    firePropertyChange("verticalFrozenLineColor", localColor, this.verticalFrozenLineColor);
    getReportPane().repaint();
  }

  public boolean isShowHorizontalFrozenLine()
  {
    return this.isShowHorizontalFrozenLine;
  }

  public void setShowHorizontalFrozenLine(boolean paramBoolean)
  {
    boolean bool = this.isShowHorizontalFrozenLine;
    this.isShowHorizontalFrozenLine = paramBoolean;
    firePropertyChange("isShowHorizontalFrozenLine", bool, this.isShowHorizontalFrozenLine);
    getReportPane().repaint();
  }

  public Color getHorizontalFrozenLineColor()
  {
    return this.horizontalFrozenLineColor;
  }

  public void setHorizontalFrozenLineColor(Color paramColor)
  {
    Color localColor = this.horizontalFrozenLineColor;
    this.horizontalFrozenLineColor = paramColor;
    firePropertyChange("horizontalFrozenLineColor", localColor, this.horizontalFrozenLineColor);
    getReportPane().repaint();
  }

  public Color getSelectedBackground()
  {
    return this.selectedBackground;
  }

  public void setSelectedBackground(Color paramColor)
  {
    Color localColor = this.selectedBackground;
    this.selectedBackground = paramColor;
    firePropertyChange("selectedBackground", localColor, this.selectedBackground);
    getReportPane().repaint();
  }

  public Color getSelectedBorderLineColor()
  {
    return this.selectedBorderLineColor;
  }

  public void setSelectedBorderLineColor(Color paramColor)
  {
    Color localColor = this.selectedBorderLineColor;
    this.selectedBorderLineColor = paramColor;
    firePropertyChange("selectedBorderLineColor", localColor, this.selectedBorderLineColor);
    getReportPane().repaint();
  }

  public boolean isEditable()
  {
    return this.editable;
  }

  public void setEditable(boolean paramBoolean)
  {
    this.editable = paramBoolean;
  }

  public boolean isSupportCellEditorDef()
  {
    return this.supportCellEditorDef;
  }

  public void setSupportCellEditorDef(boolean paramBoolean)
  {
    this.supportCellEditorDef = paramBoolean;
  }

  public boolean isCellDragable()
  {
    return this.cellDragable;
  }

  public void setCellDragable(boolean paramBoolean)
  {
    this.cellDragable = paramBoolean;
  }

  public FloatElement getDrawingFloatElement()
  {
    return this.drawingFloatElement;
  }

  public void setDrawingFloatElement(FloatElement paramFloatElement)
  {
    this.drawingFloatElement = paramFloatElement;
  }

  public int getVerticalValue()
  {
    return this.verticalValue;
  }

  public void setVerticalValue(int paramInt)
  {
    this.verticalValue = paramInt;
  }

  public int getVerticalExtent()
  {
    return this.verticalExtent;
  }

  public void setVerticalExtent(int paramInt)
  {
    this.verticalExtent = paramInt;
  }

  public int getVerticalBeginValue()
  {
    return this.verticalBeginValue;
  }

  public void setVerticalBeinValue(int paramInt)
  {
    this.verticalBeginValue = paramInt;
  }

  public boolean isDragPermited()
  {
    return this.isDragPermited;
  }

  public void setDragPermited(boolean paramBoolean)
  {
    this.isDragPermited = paramBoolean;
  }

  public int getHorizontalExtent()
  {
    return this.horizontalExtent;
  }

  public void setHorizontalExtent(int paramInt)
  {
    this.horizontalExtent = paramInt;
  }

  public int getHorizontalValue()
  {
    return this.horizontalValue;
  }

  public void setHorizontalValue(int paramInt)
  {
    this.horizontalValue = paramInt;
  }

  public int getHorizontalBeginValue()
  {
    return this.horizontalBeginValue;
  }

  public void setHorizontalBeginValue(int paramInt)
  {
    this.horizontalBeginValue = paramInt;
  }

  public boolean isEditing()
  {
    return (this.editorComponent != null);
  }

  public boolean isCellEditing()
  {
    return ((isEditing()) && (this.cellEditor != null));
  }

  public boolean isFloatEditing()
  {
    return ((isEditing()) && (this.floatEditor != null));
  }

  public CellEditor getCellEditor(int paramInt1, int paramInt2)
  {
    ReportPane localReportPane = getReportPane();
    TemplateReport localTemplateReport = localReportPane.getEditingReport();
    CellElement localCellElement = localTemplateReport.getCellElement(paramInt1, paramInt2);
    Class localClass = Object.class;
    if ((localCellElement != null) && (localCellElement.getValue() != null))
      localClass = localCellElement.getValue().getClass();
    return getDefaultCellEditor(localClass);
  }

  public Component getEditorComponent()
  {
    return this.editorComponent;
  }

  public int getEditingColumn()
  {
    return this.editingColumn;
  }

  public void setEditingColumn(int paramInt)
  {
    this.editingColumn = paramInt;
  }

  public int getEditingRow()
  {
    return this.editingRow;
  }

  public void setEditingRow(int paramInt)
  {
    this.editingRow = paramInt;
  }

  public CellEditor getCellEditor()
  {
    return this.cellEditor;
  }

  public FloatEditor getFloatEditor()
  {
    return this.floatEditor;
  }

  public void setCellEditor(CellEditor paramCellEditor)
  {
    CellEditor localCellEditor = this.cellEditor;
    this.cellEditor = paramCellEditor;
    firePropertyChange("CellEditor", localCellEditor, this.cellEditor);
  }

  public void setFloatEditor(FloatEditor paramFloatEditor)
  {
    FloatEditor localFloatEditor = this.floatEditor;
    this.floatEditor = paramFloatEditor;
    firePropertyChange("FloatEditor", localFloatEditor, this.floatEditor);
  }

  public CellEditor getDefaultCellEditor()
  {
    return getDefaultCellEditor(Object.class);
  }

  public FloatEditor getDefaultFloatEditor()
  {
    return getDefaultFloatEditor(Object.class);
  }

  public void setDefaultCellEditor(CellEditor paramCellEditor)
  {
    setDefaultCellEditor(Object.class, paramCellEditor);
  }

  public void setDefaultFloatEditor(FloatEditor paramFloatEditor)
  {
    setDefaultFloatEditor(Object.class, paramFloatEditor);
  }

  public CellEditor getDefaultCellEditor(Class paramClass)
  {
    if (paramClass == null)
      paramClass = Object.class;
    Object localObject = prepareDefaultCellEditorsByClass().get(paramClass);
    if (localObject != null)
      return ((CellEditor)localObject);
    return getDefaultCellEditor(paramClass.getSuperclass());
  }

  public FloatEditor getDefaultFloatEditor(Class paramClass)
  {
    if (paramClass == null)
      paramClass = Object.class;
    Object localObject = prepareDefaultFloatEditorsByClass().get(paramClass);
    if (localObject != null)
      return ((FloatEditor)localObject);
    return getDefaultFloatEditor(paramClass.getSuperclass());
  }

  public void setDefaultCellEditor(Class paramClass, CellEditor paramCellEditor)
  {
    if (paramCellEditor != null)
      prepareDefaultCellEditorsByClass().put(paramClass, paramCellEditor);
    else
      prepareDefaultCellEditorsByClass().remove(paramClass);
  }

  public void setDefaultFloatEditor(Class paramClass, FloatEditor paramFloatEditor)
  {
    if (paramFloatEditor != null)
      prepareDefaultFloatEditorsByClass().put(paramClass, paramFloatEditor);
    else
      prepareDefaultFloatEditorsByClass().remove(paramClass);
  }

  public void startEditing()
  {
    startEditing(null);
  }

  protected void startEditing(KeyEvent paramKeyEvent)
  {
    Object localObject1;
    ReportPane localReportPane = getReportPane();
    TemplateReport localTemplateReport = localReportPane.getEditingReport();
    GridSelection localGridSelection = localReportPane.getGridSelection();
    int i = localGridSelection.getType();
    if (i == 1)
    {
      localObject1 = localTemplateReport.getFloatElement(localGridSelection.getFloatName(0));
      stopEditing();
      Object localObject2 = ((FloatElement)localObject1).getValue();
      this.floatEditor = null;
      if (this.floatEditor == null)
        if (localObject2 == null)
          this.floatEditor = getDefaultFloatEditor();
        else
          this.floatEditor = getDefaultFloatEditor(localObject2.getClass());
      if (this.floatEditor == null)
      {
        this.editorComponent = null;
        return;
      }
      this.editorComponent = this.floatEditor.getFloatEditorComponent(this, (FloatElement)localObject1);
      if (this.editorComponent == null)
      {
        removeEditor();
        return;
      }
      this.floatEditor.addFloatEditorListener(this.innerFloatEditorListener);
      setFloatEditor(this.floatEditor);
      if (this.editorComponent instanceof Window)
      {
        this.editorComponent.setVisible(true);
      }
      else
      {
        ajustEditorComponentBounds(getReportPane());
        add(this.editorComponent);
        validate();
        this.editorComponent.requestFocus();
        repaint(10L);
      }
    }
    else if (isCellSelectable())
    {
      localObject1 = localGridSelection.getEditRectangle();
      startCellEditingAt(((Rectangle)localObject1).x, ((Rectangle)localObject1).y, paramKeyEvent);
    }
  }

  public boolean startCellEditingAt(int paramInt1, int paramInt2)
  {
    return startCellEditingAt_DEC(paramInt1, paramInt2, null, null);
  }

  public boolean startCellEditingAt(int paramInt1, int paramInt2, KeyEvent paramKeyEvent)
  {
    return startCellEditingAt_DEC(paramInt1, paramInt2, null, paramKeyEvent);
  }

  public boolean startCellEditingAt_DEC(int paramInt1, int paramInt2, Class paramClass, KeyEvent paramKeyEvent)
  {
    if (isEditing())
      stopEditing();
    if (!(isEditable()))
      return false;
    if ((paramInt2 < 0) || (paramInt1 < 0))
      return false;
    ReportPane localReportPane = getReportPane();
    TemplateReport localTemplateReport = localReportPane.getEditingReport();
    this.editingCellElement = localTemplateReport.getCellElement(paramInt1, paramInt2);
    if (paramClass == null)
      this.cellEditor = getCellEditor(paramInt1, paramInt2);
    else
      this.cellEditor = getDefaultCellEditor(paramClass);
    if (this.cellEditor == null)
    {
      this.editorComponent = null;
      return false;
    }
    if (this.editingCellElement == null)
    {
      this.editingCellElement = new DefaultCellElement(paramInt1, paramInt2);
      localTemplateReport.addCellElement(this.editingCellElement);
    }
    this.editorComponent = this.cellEditor.getCellEditorComponent(this, this.editingCellElement);
    if (this.editorComponent == null)
    {
      removeEditor();
      return false;
    }
    this.editorComponentLoc = this.cellEditor.getLocationOnCellElement();
    this.cellEditor.addCellEditorListener(this.innerCellEditorListener);
    setCellEditor(this.cellEditor);
    setEditingColumn(paramInt1);
    setEditingRow(paramInt2);
    if (this.editorComponent instanceof Window)
    {
      SwingUtilities.invokeLater(new Runnable(this)
      {
        private final Grid this$0;

        public void run()
        {
          if (this.this$0.editorComponent != null)
            this.this$0.editorComponent.setVisible(true);
        }
      });
    }
    else
    {
      if ((paramKeyEvent != null) && (this.editorComponent instanceof JTextField))
        ((JTextField)this.editorComponent).setText("");
      this.editingRow = this.editingCellElement.getRow();
      this.editingColumn = this.editingCellElement.getColumn();
      ajustEditorComponentBounds(getReportPane());
      add(this.editorComponent);
      localReportPane.ensureColumnRowVisible(paramInt1, paramInt2);
      validate();
      repaint(10L);
      this.editorComponent.requestFocus();
    }
    return true;
  }

  public void stopEditing()
  {
    if (isCellEditing())
      stopCellEditingInner(true);
    if (isFloatEditing())
      stopFloatEditingInner(true);
  }

  private void stopFloatEditingInner(boolean paramBoolean)
  {
    if (!(isFloatEditing()))
      return;
    FloatEditor localFloatEditor = this.floatEditor;
    if (localFloatEditor == null)
    {
      if (this.editorComponent != null)
        remove(this.editorComponent);
      return;
    }
    Object localObject1 = null;
    try
    {
      localObject1 = localFloatEditor.getFloatEditorValue();
    }
    catch (Exception localException)
    {
      FRContext.getLogger().log(Level.SEVERE, localException.getMessage(), localException);
    }
    if (localObject1 == null)
    {
      removeEditor();
      return;
    }
    ReportPane localReportPane = getReportPane();
    TemplateReport localTemplateReport = localReportPane.getEditingReport();
    GridSelection localGridSelection = localReportPane.getGridSelection();
    FloatElement localFloatElement = localTemplateReport.getFloatElement(localGridSelection.getFloatName(0));
    Object localObject2 = localFloatElement.getValue();
    if (!(ComparatorUtils.equals_exactly(localObject2, localObject1)))
    {
      localFloatElement.setValue(localObject1);
      setDataChanged(true);
    }
    if (isDataChanged())
    {
      setDataChanged(false);
      localReportPane.fireReportDataChanged();
      localReportPane.undoRecord();
    }
    removeEditor();
    if ((paramBoolean) && (!(hasFocus())))
      requestFocus();
  }

  private void stopCellEditingInner(boolean paramBoolean)
  {
    Object localObject2;
    Object localObject3;
    if (!(isCellEditing()))
      return;
    CellEditor localCellEditor = this.cellEditor;
    if (localCellEditor == null)
    {
      if (this.editorComponent != null)
        remove(this.editorComponent);
      return;
    }
    ReportPane localReportPane = getReportPane();
    TemplateReport localTemplateReport = localReportPane.getEditingReport();
    Object localObject1 = null;
    try
    {
      localObject1 = localCellEditor.getCellEditorValue();
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    if (localObject1 == null)
    {
      removeEditor();
      return;
    }
    this.editingCellElement = localTemplateReport.getCellElement(this.editingColumn, this.editingRow);
    if (this.editingCellElement == null)
    {
      if (localObject1 instanceof String)
      {
        if (((String)localObject1).length() > 0)
          this.editingCellElement = new DefaultCellElement(this.editingColumn, this.editingRow, localObject1);
      }
      else if (localObject1 instanceof CellElement)
      {
        localObject2 = (CellElement)localObject1;
        this.editingCellElement = new DefaultCellElement(this.editingColumn, this.editingRow, ((CellElement)localObject2).getValue());
        this.editingCellElement.setCellExpandAttr(((CellElement)localObject2).getCellExpandAttr());
      }
      else if (localObject1 instanceof CellImage)
      {
        localObject2 = (CellImage)localObject1;
        localObject1 = ((CellImage)localObject2).getImage();
        this.editingCellElement = new DefaultCellElement(this.editingColumn, this.editingRow, localObject1);
        if (((CellImage)localObject2).getStyle() != null)
          this.editingCellElement.setStyle(((CellImage)localObject2).getStyle());
      }
      else
      {
        this.editingCellElement = new DefaultCellElement(this.editingColumn, this.editingRow, localObject1);
      }
      if (this.editingCellElement != null)
      {
        localTemplateReport.addCellElement(this.editingCellElement);
        setDataChanged(true);
      }
    }
    else if (localObject1 instanceof CellElement)
    {
      localObject2 = (CellElement)localObject1;
      this.editingCellElement.setValue(((CellElement)localObject2).getValue());
      this.editingCellElement.setCellExpandAttr(((CellElement)localObject2).getCellExpandAttr());
      setDataChanged(true);
    }
    else if (localObject1 instanceof CellImage)
    {
      localObject2 = (CellImage)localObject1;
      localObject1 = ((CellImage)localObject2).getImage();
      localObject3 = this.editingCellElement.getValue();
      if (!(ComparatorUtils.equals_exactly(localObject3, localObject1)))
      {
        this.editingCellElement.setValue(localObject1);
        setDataChanged(true);
      }
      if (((CellImage)localObject2).getStyle() != null)
        this.editingCellElement.setStyle(((CellImage)localObject2).getStyle());
    }
    else
    {
      localObject2 = this.editingCellElement.getValue();
      if (!(ComparatorUtils.equals_exactly(localObject2, localObject1)))
      {
        this.editingCellElement.setValue(localObject1);
        setDataChanged(true);
      }
    }
    if (isDataChanged())
    {
      double d2;
      int k;
      setDataChanged(false);
      if (this.editingCellElement != null)
      {
        localObject2 = this.editingCellElement.getValue();
        if ((localObject2 != null) && (((localObject2 instanceof String) || (localObject2 instanceof Number))))
        {
          double d1;
          int j;
          localObject3 = ReportHelper.getColumnWidthList(localTemplateReport);
          DynamicValueList localDynamicValueList = ReportHelper.getRowHeightList(localTemplateReport);
          int i = this.editingCellElement.getColumn();
          ReportSettings localReportSettings = localTemplateReport.getReportSettings();
          if (localReportSettings == null)
            localReportSettings = new ReportSettings();
          CellGUIAttr localCellGUIAttr = this.editingCellElement.getCellGUIAttr();
          if (localCellGUIAttr == null)
            localCellGUIAttr = new CellGUIAttr();
          if ((localCellGUIAttr.getAdjustMode() == 1) || ((localCellGUIAttr.getAdjustMode() == 3) && (localReportSettings.getShrinkToFitMode() == 1)))
          {
            d1 = PaintUtils.analyzeCellElementPreferredHeight(this.editingCellElement, ((DynamicValueList)localObject3).getRangeValue(i, i + this.editingCellElement.getColumnSpan()));
            if (this.editingCellElement.getRowSpan() == 1)
            {
              localDynamicValueList.set(this.editingCellElement.getRow(), (int)Math.max(d1, localDynamicValueList.get(this.editingCellElement.getRow())));
              break label1064:
            }
            j = this.editingCellElement.getRow() + this.editingCellElement.getRowSpan() - 1;
            d2 = d1 - localDynamicValueList.getRangeValue(this.editingCellElement.getRow(), j + 1);
            if (d2 <= 0.0D)
              break label1064;
            k = this.editingCellElement.getRow();
            while (true)
            {
              if (k > j)
                break label1064;
              localDynamicValueList.set(k, (int)(localDynamicValueList.get(k) + d2 / this.editingCellElement.getRowSpan()));
              ++k;
            }
          }
          if ((localCellGUIAttr.getAdjustMode() == 2) || ((localCellGUIAttr.getAdjustMode() == 3) && (localReportSettings.getShrinkToFitMode() == 2)))
          {
            d1 = PaintUtils.getPreferredWidth(this.editingCellElement, localDynamicValueList.getRangeValue(this.editingCellElement.getRow(), this.editingCellElement.getRow() + this.editingCellElement.getRowSpan()));
            if (this.editingCellElement.getColumnSpan() == 1)
            {
              ((DynamicValueList)localObject3).set(this.editingCellElement.getColumn(), (int)Math.max(d1, ((DynamicValueList)localObject3).get(this.editingCellElement.getColumn())));
            }
            else
            {
              j = this.editingCellElement.getColumn() + this.editingCellElement.getColumnSpan() - 1;
              d2 = d1 - ((DynamicValueList)localObject3).getRangeValue(this.editingCellElement.getColumn(), j + 1);
              if (d2 > 0.0D)
                for (k = this.editingCellElement.getColumn(); k <= j; ++k)
                  ((DynamicValueList)localObject3).set(k, (int)(((DynamicValueList)localObject3).get(k) + d2 / this.editingCellElement.getColumnSpan()) + 1);
            }
          }
        }
      }
      label1064: localReportPane.fireReportDataChanged();
      localReportPane.undoRecord();
    }
    removeEditor();
    if ((paramBoolean) && (!(hasFocus())))
      requestFocus();
  }

  public void cancelEditing()
  {
    if (isEditing())
    {
      removeEditor();
      requestFocus();
    }
  }

  public void removeEditor()
  {
    if (isCellEditing())
    {
      removeCellEditor();
    }
    else
    {
      FloatEditor localFloatEditor = getFloatEditor();
      if (localFloatEditor != null)
      {
        if (this.editorComponent != null)
          if (this.editorComponent instanceof Window)
          {
            this.editorComponent.setVisible(false);
            ((Window)this.editorComponent).dispose();
          }
          else
          {
            remove(this.editorComponent);
            validate();
          }
        localFloatEditor.removeFloatEditorListener(this.innerFloatEditorListener);
      }
      setFloatEditor(null);
      this.editorComponent = null;
      getReportPane().repaint();
    }
  }

  public void removeCellEditor()
  {
    CellEditor localCellEditor = getCellEditor();
    if (localCellEditor == null)
      return;
    if (this.editorComponent != null)
      if (this.editorComponent instanceof Window)
      {
        this.editorComponent.setVisible(false);
        ((Window)this.editorComponent).dispose();
      }
      else
      {
        remove(this.editorComponent);
        validate();
      }
    localCellEditor.removeCellEditorListener(this.innerCellEditorListener);
    setCellEditor(null);
    setEditingColumn(-1);
    setEditingRow(-1);
    this.editorComponent = null;
    this.editingCellElement = null;
    getReportPane().repaint();
  }

  private Hashtable prepareDefaultCellEditorsByClass()
  {
    if (this.defaultCellEditorsByClass == null)
    {
      this.defaultCellEditorsByClass = new Hashtable();
      this.defaultCellEditorsByClass.put(Object.class, new GeneralCellEditor());
    }
    return this.defaultCellEditorsByClass;
  }

  private Hashtable prepareDefaultFloatEditorsByClass()
  {
    if (this.defaultFloatEditorsByClass == null)
    {
      this.defaultFloatEditorsByClass = new Hashtable();
      this.defaultFloatEditorsByClass.put(Object.class, new GeneralFloatEditor());
    }
    return this.defaultFloatEditorsByClass;
  }

  public void doMousePress(double paramDouble1, double paramDouble2)
  {
    dispatchEvent(new MouseEvent(this, 501, System.currentTimeMillis(), 0, (int)paramDouble1, (int)paramDouble2, 1, false));
  }

  public Rectangle caculateIntersectsUnion(Report paramReport, Rectangle paramRectangle)
  {
    Rectangle localRectangle1 = new Rectangle(paramRectangle);
    Iterator localIterator = paramReport.intersect(localRectangle1.x, localRectangle1.y, localRectangle1.width, localRectangle1.height);
    while (true)
    {
      Rectangle localRectangle2;
      do
      {
        if (!(localIterator.hasNext()))
          break label120;
        CellElement localCellElement = (CellElement)localIterator.next();
        localRectangle2 = new Rectangle(localCellElement.getColumn(), localCellElement.getRow(), localCellElement.getColumnSpan(), localCellElement.getRowSpan());
      }
      while ((!(localRectangle1.intersects(localRectangle2))) || (localRectangle1.contains(localRectangle2)));
      localRectangle1 = localRectangle1.union(localRectangle2);
    }
    if (!(localRectangle1.equals(paramRectangle)))
      label120: return caculateIntersectsUnion(paramReport, localRectangle1);
    return localRectangle1;
  }

  public Point getToolTipLocation(MouseEvent paramMouseEvent)
  {
    if (StringUtils.isEmpty(getToolTipText()))
      return null;
    return this.tooltipLocation;
  }

  public void ajustEditorComponentBounds(ReportPane paramReportPane)
  {
    double d1;
    double d2;
    double d3;
    double d4;
    int k;
    if (this.editorComponent == null)
      return;
    if (this.editorComponent instanceof Window)
      return;
    DynamicValueList localDynamicValueList1 = ReportHelper.getRowHeightList(paramReportPane.getEditingReport());
    DynamicValueList localDynamicValueList2 = ReportHelper.getColumnWidthList(paramReportPane.getEditingReport());
    TemplateReport localTemplateReport = paramReportPane.getEditingReport();
    GridSelection localGridSelection = paramReportPane.getGridSelection();
    int i = localGridSelection.getType();
    if (i == 1)
    {
      FloatElement localFloatElement = localTemplateReport.getFloatElement(localGridSelection.getFloatName(0));
      k = localFloatElement.getColumn();
      int l = localFloatElement.getRow();
      d1 = localDynamicValueList2.getRangeValue(this.horizontalBeginValue, k);
      d1 += localFloatElement.getLeftDistance();
      d2 = localDynamicValueList1.getRangeValue(this.verticalBeginValue, l);
      d2 += localFloatElement.getTopDistance();
      d3 = localFloatElement.getSize().getWidth();
      d4 = localFloatElement.getSize().getHeight();
    }
    else
    {
      d1 = localDynamicValueList2.getRangeValue(this.horizontalBeginValue, this.editingColumn);
      d2 = localDynamicValueList1.getRangeValue(this.verticalBeginValue, this.editingRow);
      int j = 1;
      k = 1;
      if (this.editingCellElement != null)
      {
        j = this.editingCellElement.getColumnSpan();
        k = this.editingCellElement.getRowSpan();
      }
      d3 = localDynamicValueList2.getRangeValue(this.editingColumn, this.editingColumn + j) - 1;
      d4 = localDynamicValueList1.getRangeValue(this.editingRow, this.editingRow + k) - 1;
    }
    if (this.editorComponentLoc == null)
      this.editorComponent.setLocation((int)(d1 + 1.0D), (int)(d2 + 1.0D));
    else
      this.editorComponent.setLocation((int)(d1 + this.editorComponentLoc.getX()), (int)(d2 + this.editorComponentLoc.getY()));
    if (this.editorComponent instanceof JTextField)
    {
      Dimension localDimension = this.editorComponent.getPreferredSize();
      if (this.editorComponentLoc == null)
        this.editorComponent.setSize((int)Math.max(d3, localDimension.getWidth() + 1.0D), (int)d4);
      else
        this.editorComponent.setSize((int)(Math.max(d3, localDimension.getWidth() + 1.0D) - this.editorComponentLoc.getX()), (int)(d4 - this.editorComponentLoc.getY()));
    }
    else if (this.editorComponentLoc == null)
    {
      this.editorComponent.setSize((int)d3, (int)d4);
    }
    else
    {
      this.editorComponent.setSize((int)(d3 - this.editorComponentLoc.getX()), (int)(d4 - this.editorComponentLoc.getY()));
    }
  }

  public int getEnterMoveDirection()
  {
    return this.enterMoveDirection;
  }

  public void setEnterMoveDirection(int paramInt)
  {
    this.enterMoveDirection = paramInt;
  }

  public int getTabMoveDirection()
  {
    return this.tabMoveDirection;
  }

  public void setTabMoveDirection(int paramInt)
  {
    this.tabMoveDirection = paramInt;
  }

  public boolean isCellSelectable()
  {
    return this.cellSelectable;
  }

  public void setCellSelectable(boolean paramBoolean)
  {
    boolean bool = this.cellSelectable;
    this.cellSelectable = paramBoolean;
    firePropertyChange("cellSelectable", bool, this.cellSelectable);
    getReportPane().repaint();
    this.cellSelectable = paramBoolean;
  }

  public void setDragType(int paramInt)
  {
    this.dragType = paramInt;
  }

  public int getDragType()
  {
    return this.dragType;
  }

  public void setDragRectangle(Rectangle paramRectangle)
  {
    this.dragRectangle = paramRectangle;
  }

  public Rectangle getDragRectangle()
  {
    return this.dragRectangle;
  }

  public void setDataChanged(boolean paramBoolean)
  {
    this.isDataChanged = paramBoolean;
  }

  public boolean isDataChanged()
  {
    return this.isDataChanged;
  }

  public void setTooltipLocation(double paramDouble1, double paramDouble2)
  {
    this.tooltipLocation.setLocation(paramDouble1, paramDouble2);
  }

  static void access$000(Grid paramGrid, boolean paramBoolean)
  {
    paramGrid.stopCellEditingInner(paramBoolean);
  }

  static void access$100(Grid paramGrid, boolean paramBoolean)
  {
    paramGrid.stopFloatEditingInner(paramBoolean);
  }
}